﻿using System;
using System.Data.Common;
using MayfairFramework.Common.DI;

namespace MayfairFramework.Transaction
{
    public abstract class ConnectionManager
    {
        abstract protected bool isTransactionBegining(MethodInvocation mi);
        abstract public DbConnection getCurrentConnection(MethodInvocation mi);
        abstract public void beginTransaction(MethodInvocation mi);
        abstract public void rollback(MethodInvocation mi);
        abstract public void commit(MethodInvocation mi);

        public static readonly String CONNECTION_MANAGER_KEY = "ConnectionManager";

        public static ConnectionManager GetConnectionManager()
        {
            DIContainer container = DIContainerFactory.GetDIContainer();
            return (ConnectionManager)container.GetObject<ConnectionManager>(CONNECTION_MANAGER_KEY);
        }
    }

    public interface MethodInvocation
    {
    }
}
